var publicUrl = '/';
var layer;
$(function(){
	layui.use('layer',function(){
		layer = layui.layer;
	})
})
//var publicUrl = 'http://192.168.1.16:3080/online_monitoring/'
//var publicUrl = 'http://192.168.1.71:3080/'
//var publicUrl = 'http://192.168.1.170:3080/online_monitoring/'
//var publicUrl = 'http://192.168.1.228:18088/online_monitoring/'
function publicAjax (url,params,callback,header) {
	
	$.ajax({
		type:"post",
		url: publicUrl + url,
		async:true,
		data:params,
		headers:header,
		error: function (error){
			console.log(error);
		},
		success: function (data){
			if(data.code == 506){
				layui.use('layer',function(){
					var layer = layui.layer;
					layer.msg(data.msg, {
						time: 1000
					}, function() {
						window.location.href = "/authentication/login.html";
					})
				})
			}else if(data.code == 405){
                layui.use('layer',function(){
                    var layer = layui.layer;
                    layer.msg(data.msg, {
                        time: 1000
                    }, function() {
                    	window.location.href = "/authentication/login.html";
                    })
                })
			}else{
                callback(data);
			}
		},
		error:function(XMLHttpRequest, textStatus, errorThrown){
			/*if(XMLHttpRequest.status=="401"){
				layer.msg($.parseJSON(XMLHttpRequest.responseText).msg,{icon:5},function(){
					window.location.href = "/authentication/login.html";
				})
			}else{*/
				layer.msg("服务鉴权失败",{icon:5},function(){
					window.location.href = "/authentication/login.html";
				})
			/*}*/
		}
	});
}
$.fn.serializeJson = function () {
     var serializeObj = {};
     $(this.serializeArray()).each(function () {
        serializeObj[this.name] = this.value;
    });
    return serializeObj;
};
/*
function btnContol() {
	var optType = window.parent.window.optType.split(',');
	if(optType.length == 1) {
		//		$('.xiu_btn_same').addClass('hideNone');
		$('.xiu_btn_same').attr('disabled', true).addClass('xiu_btn_same_disabled');
	} else if(optType.length == 2) {
		var num = 0;
		for(var i = 0; i < optType.length; i++) {
			if(optType[i] == 2) {
				num = 2;
			} else if(optType[i] == 3) {
				num = 3;
			}
		}
		if(num == 2) {} else if(num == 3) {
			$('.xiu_btn_same').attr('disabled', true).addClass('xiu_btn_same_disabled');
		}
	}
}

function btnContolO() {
	if(optType.length == 1) {
		$('.xiu_btn_same,.layui-btn-group input').attr('disabled', true).addClass('xiu_btn_same_disabled');
		$("").attr('disabled', true);
	} else if(optType.length == 2) {
		var num = 0;
		for(var i = 0; i < optType.length; i++) {
			if(optType[i] == 2) {
				num = 2;
			} else if(optType[i] == 3) {
				num = 3;
			}
		}
		if(num == 2) {
			$('.xiu_btn_same_shan').attr('disabled', true).addClass('xiu_btn_same_disabled');
		} else if(num == 3) {
			$('.xiu_btn_same,.layui-btn-group input').attr('disabled', true).addClass('xiu_btn_same_disabled');
			$('.xiu_btn_same_shan').removeAttr('disabled').removeClass('xiu_btn_same_disabled');

		}
	}
}

function btnContolT() {
	if(optType.length == 1) {
		$('.layui-table-cell img').removeAttr('lay-event').addClass('xiu_btn_same_disabled_lay');
	} else if(optType.length == 2) {
		var num = 0;
		for(var i = 0; i < optType.length; i++) {
			if(optType[i] == 2) {
				num = 2;
			} else if(optType[i] == 3) {
				num = 3;
			}
		}
		if(num == 2) {} else if(num == 3) {
			$('.layui-table-cell img').removeAttr('lay-event').addClass('xiu_btn_same_disabled_lay');
		}
	}
}*/
